package com.goldmantis.alitrip.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.goldmantis.alitrip.common.BaseService;
import com.goldmantis.alitrip.common.utils.ToolUtil;
import com.goldmantis.alitrip.mapper.SysSubsystemMapper;
import com.goldmantis.alitrip.pojo.SysRes;
import com.goldmantis.alitrip.pojo.SysSubsystem;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * @Author:Shmily
 * @Description:
 * @Date:Create in 9:46 2018/2/11
 */
@Service
public class SysSubsystemService extends BaseService<SysSubsystem> {

    @Autowired
    private SysSubsystemMapper sysSubsystemMapper;




    @Override
    public PageInfo<SysSubsystem> pageList(SysSubsystem t, Integer offset, Integer limit){
        if(limit==null) {
            limit=Integer.MAX_VALUE;
        }
        PageHelper.startPage(offset, limit);

        Example example=new Example(SysSubsystem.class);
        example.setOrderByClause("CREATETIME DESC ");
        Example.Criteria criteria = example.createCriteria();

        if(StringUtils.isNotBlank(t.getSysname())) {
            criteria.andLike("sysname", ToolUtil.combineLikeOperator(t.getSysname()));
        }
        List<SysSubsystem> sysSubsystems = this.sysSubsystemMapper.selectByExample(example);
        return new PageInfo(sysSubsystems);
    }
}
